import pytest
import requests
from data.read_data import read_tpshopRegister
from scripts.hm02_api1 import RegisterApi
from scripts.hm03_assert1 import TpshopRegister

code = RegisterApi()
assert1 = TpshopRegister()


class TestTpshopRegister:
    # 定义类属性
    session = None

    def setup_class(self):
        self.session = requests.session()

    def setup(self):
        code.get_verify_code01(self.session)

    @pytest.mark.parametrize("username, verify_code, password, password2, state_code, status, msg",
                             read_tpshopRegister())
    def test(self, username, verify_code, password, password2, state_code, status, msg):
        register_data = {"username": username,
                         "verify_code": verify_code,
                         "password": password,
                         "password2": password2}
        print("register_data=", register_data)
        register_result = code.register(self.session, register_data)
        assert1.register_assert(register_result, state_code, status, msg)
